//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.dao.wills;

import com.aidong.dao.base.ConditionMap;
import com.aidong.dao.base.Pagination;
import com.aidong.dao.wills.BaseDao;
import com.aidong.model.wills.PtChangeCoach;
import java.util.ArrayList;
import org.springframework.stereotype.Repository;

@Repository
public class PtChangeCoachDao extends BaseDao<PtChangeCoach, Integer> {
	public PtChangeCoachDao() {
	}

	public void queryPageList(Pagination<PtChangeCoach> pg, ConditionMap cd) {
		ArrayList params = new ArrayList();
		String sqlw = cd.toSql(params);
		String sql = "select b.autoId,b.shopCode,b.contractCode,b.memberCode, ptCode,coachCode, newCoachCode, m.chName memberName, b.createTime\nfrom PtChangeCoach b inner join MemberInfo m on b.memberCode=m.memberCode\n" + (sqlw.length() > 0?"where " + sqlw:"") + " order by b.createTime desc";
		this.queryPageListBySql(PtChangeCoach.class, pg, sql, params.toArray());
	}

	public void addChangeCoach(PtChangeCoach changeCoach) {
		this.add(changeCoach);
		String sql = "update PtContract set coachCode=:p1, updateTime=getdate() where contractCode=:p2";
		this.updateBySql(sql, new Object[]{changeCoach.getNewCoachCode(), changeCoach.getContractCode()});
	}
}
